﻿using HZH_Controls.Controls;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using 渐变.common;
using 渐变.model;

namespace 渐变.user_Form
{
    public partial class user_welcome : Form
    {
      
        public user_welcome()
        {
            InitializeComponent();
        }
        public void loadMsg()
        {
            List<DataGridViewColumnEntity> lstCulumns = new List<DataGridViewColumnEntity>();
            lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "title", HeadText = "标题", Width = 30, WidthType = SizeType.Percent });
            lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "createtime", HeadText = "发布时间", Width = 60, WidthType = SizeType.Percent });

            this.ucDataGridView1.Columns = lstCulumns;
            //this.ucDataGridView1.IsShowCheckBox = true;
            string sql = "select * from notice";
            DataTable dt = DBHelper.ExecuteQuery(sql);
            ModelHandler<model.notice> mconvert = new common.ModelHandler<model.notice>();
            var list = mconvert.FillModel(dt);

            this.ucDataGridView1.DataSource = list;
            //this.ucDataGridView1.First();
            //设置是否允许自动生成列

        }
        private void user_welcome_Load(object sender, EventArgs e)
        {
            this.Dock =  DockStyle.Fill;
            loadMsg();
           /*user_shadowNotice shadowNotice = new user_shadowNotice();
            shadowNotice.MdiParent = this;
            shadowNotice.Parent = panel1;
            shadowNotice.Show();*/
        }

        private void ucDataGridView1_ItemClick(object sender, DataGridViewEventArgs e)
        {
            var row = ucDataGridView1.SelectRow;
            if (row.DataSource != null)
            {
                var model = (row.DataSource as notice);
                FrmNotice frm = new FrmNotice(model);
                frm.StartPosition = FormStartPosition.CenterParent;
                frm.ShowDialog(this);
                //弹出层
                //FrmWithTitle frm = new FrmWithTitle();
                //frm.Show();
            }
        }

        private void versiondata_Load(object sender, EventArgs e)
        {
            List<DataGridViewColumnEntity> lstCulumns = new List<DataGridViewColumnEntity>(); 
            lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "title", Width = 30, WidthType = SizeType.Percent });
            lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "content", Width = 60, WidthType = SizeType.Percent });
           
            this.versiondata.Columns = lstCulumns;
            List<object> lstSource = new List<object>();
            TestModel model = new TestModel();
            model.title = "系统名称";
            model.content = "汽车出租管理系统";
            lstSource.Add(model);

            TestModel model1 = new TestModel();
            model1.title = "当前版本";
            model1.content = "V1.0.0";
            lstSource.Add(model1);

            TestModel model2 = new TestModel();
            model2.title = "数据库版本";
            model2.content = "SQL Server2019";
            lstSource.Add(model2);

            TestModel model3 = new TestModel();
            model3.title = "托管平台";
            model3.content = "gitee";
            lstSource.Add(model3);

            TestModel model4 = new TestModel();
            
           
            

            this.versiondata.DataSource = lstSource;
            this.versiondata.First();
        }
    }
}
